<?php

namespace Modules\Edu\Http\Controllers\Front;

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Modules\Edu\Entities\Lesson;
use Modules\Edu\Entities\Tag;

class LessonController extends Controller
{

    public function index(Request $request)
    {

        $lessons=Lesson::site()->Search($request->w)->SearchTag($request->query('tag'))->latest();
        if (\Browser::isMobile()) {
            $lessons=$lessons->simplePaginate(3);
        } else {
            $lessons = $lessons->paginate(12);
        }
        $tags=Tag::Site()->get();
        return view('edu::lesson_front.index', compact('lessons','tags'));
    }
    public function show(Lesson $lesson)
    {
        $videos=$lesson->videos;
        return view('edu::lesson_front.show',compact('lesson','videos'));
    }
}
